-
Notifications
You must be signed in to change notification settings - Fork 208
Extend PR #3089 – Complete Fiat Input Support in Dual Currency Field #3394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Extend PR #3089 – Complete Fiat Input Support in Dual Currency Field #3394
Conversation
|
hi @pavanjoshi914 , there were three test failing initaially, the recent push i made fixed two of them, so presently only one test is failing, and that's for i noticed the test added for "set new budget" might be a bit too tightly coupled to the internal formatting behavior especially the exact number and order of calls to mockGetFormattedInCurrency as each digit is typed (2 → 25 → 250). This makes the test a bit fragile and implementation-dependent, it could start failing if, for instance, the input handling is optimized (e.g. with debouncing or batching), even if the feature still behaves correctly for users. It might be more robust to:
Interestingly, the initial version of the test (with mockGetFiatValue) already leaned in this direction. it focused more on verifying that the final value was passed and that the right callbacks were triggered, without overasserting internal details. It just needs updating to reflect the current DualCurrencyField implementation and the mockGetFormattedInCurrency function. That way the test better reflects actual user-facing correctness without being overly strict on internals. |
|
i can rewrite the test to better illustrate what i’m suggesting if editing the test is welcomed. |
|
yup if it makes sense |
alright, i would do that. |
|
I refactored the effect that syncs the external value prop with the internal input state in DualCurrencyField to improve clarity, performance, and correctness. The previous logic was doing multiple conversions and comparisons that often led to redundant state updates and unnecessary re-renders. It also made the control flow harder to follow so now, we track the last seen value and only run conversions when there's a meaningful change. I also ensure the input value is only updated if the final rendered value would actually change, avoiding unnecessary React updates. |
…hecks and save flow
1877599 to
03216ea
Compare
|
This PR got messy after a rebase/force-push — I’ve opened a clean version here: #3395 |
🚀 Summary
This pull request continues from where #3089 left off. That initial PR laid the groundwork, and this one builds upon it to complete the implementation and resolve remaining issues.
✨ Changes Introduced
A breakdown of what this PR introduces:
ConfirmPaymentandSitePreferences.Added a default mock implementation for
getFormattedInCurrencyin theSettingsContext. This resolves the failing unit tests inConfirmPayment/index.test.tsxcaused by a missing mock.Work is still in progress for fixing the related test cases.
🔗 Related Issues or PRs
🧩 Type of Change
Select the appropriate type:
fix: Bug fix (non-breaking change which fixes an issue)feat!: Breaking change (may break existing functionality)📸 Screenshots (optional)
Add any relevant screenshots, screen recordings, or UI diffs to help reviewers.
🧪 How This Was Tested
✅ Checklist
For UI-related changes: